/*
 * =====================================================================================
 *
 *       Filename:  TemplateMethod.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2015年01月27日 16时33分05秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  LiuYi (), swliuyi@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <limits.h>
#include <iostream>
#include <tr1/memory>

using namespace std;
class TestPaper
{
    public:
        void TestQuestion1()
        {
            cout<<"Question 1"<<endl;
            cout<<"Answer : "<<Answer1()<<endl;
        }
        void TestQuestion2()
        {
            cout<<"Question 2"<<endl;
            cout<<"Answer : "<<Answer2()<<endl;
        }
        void TestQuestion3()
        {
            cout<<"Question 3"<<endl;
            cout<<"Answer : "<<Answer3()<<endl;
        }
    protected:
        virtual string Answer1() = 0;
        virtual string Answer2() = 0;
        virtual string Answer3() = 0;
};

class TestPaperA : public TestPaper
{
    protected:
       string Answer1()
       {
           return "A";
       }
       string Answer2()
       {
           return "B";
       }
       string Answer3()
       {
           return "C";
       }
};

class TestPaperB : public TestPaper
{
    protected:
       string Answer1()
       {
           return "B";
       }
       string Answer2()
       {
           return "D";
       }
       string Answer3()
       {
           return "C";
       }
};

int main(int argc, char *argv[])
{
    tr1::shared_ptr<TestPaper> tpA(new TestPaperA);
    tpA->TestQuestion1();  
    tpA->TestQuestion2();  
    tpA->TestQuestion3();  

    tr1::shared_ptr<TestPaper> tpB(new TestPaperB);
    tpB->TestQuestion1();  
    tpB->TestQuestion2();  
    tpB->TestQuestion3();  
}
